<template>
  <Modal
    :visible="showModal"
    @cancel="closeModal"
    title="扩容文件系统"
    okText="确认"
    @ok="submitForm"
    cancelText="取消"
  >
    <div class="text-sl-textGray text-12px mb-10px text-sm">当前文件系统大小【{{ props.minSize }}GB】</div>
    <div class="text-sl-textGray text-12px mb-10px text-sm">
      扩容后需大于当前文件系统大小，可选择的容量大小为【{{ props.minSize + 1 }}GB】~【327680GB】
    </div>
    <span>扩容后文件系统的新容量： </span>
    <InputNumber class="w-85px" :max="327680" :min="props.minSize + 1" v-model:value="size" /> GB
  </Modal>
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import { Modal, InputNumber } from 'ant-design-vue';
import { expandSfsTurobo } from '../../../api/system-mgmt/appfs-mgmt/appfs';

const emits = defineEmits(['expandSuccess']);
const showModal = ref<boolean>(false);
const props = defineProps({
  appId: {
    type: String,
  },
  sfsUuid: {
    type: String,
  },
  minSize: {
    type: Number,
  },
});
const openModal = () => {
  showModal.value = true;
};
const size = ref<number>(props.size);

const closeModal = () => {
  showModal.value = false;
};

const submitForm = async () => {
  await expandSfsTurobo({
    sfsUUid: props.sfsUuid,
    size: size.value,
    appId: props.appId,
  });
  emits('expandSuccess');

  closeModal();
};

defineExpose({ openModal, closeModal });
</script>

<style lang="less" scoped></style>
